﻿using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using System.Linq.Expressions;

namespace _11Net8AspNetCore_WebApis.BandModel
{
    /// <summary>
    /// Cookie 模型绑定提供者对象
    /// </summary>
    public class CookieModelBinderProdver : IModelBinderProvider
    {
        /// <summary>
        /// 提供CookieModerBinder 
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public IModelBinder? GetBinder(ModelBinderProviderContext context)
        {
            if (context.Metadata.ModelType.Equals(typeof(CookieBangModel)))
            {
                return new BinderTypeModelBinder(typeof(CookieBangModel));
            }
            return null;
        }
    }
}
